# 题目五 - 3 : 使用ORB检测角点
import cv2 as cv
import numpy as np

# 读取图像以及90度旋转图像
filename = r"D:\AI\Picture\left03.jpg"
img1 = cv.imread(filename)
img2 = np.rot90(img1)
# 转换为灰度图
gray1 = cv.cvtColor(img1, cv.COLOR_BGR2GRAY)
gray2 = cv.cvtColor(img2, cv.COLOR_BGR2GRAY)
# 创建orb算子以及提取描述子
orb = cv.ORB_create()
k1, dst1 = orb.detectAndCompute(gray1, None)
k2, dst2 = orb.detectAndCompute(gray2, None)
# 创建FBMatcher类对象，并且进行匹配
BF = cv.BFMatcher(cv.NORM_L2)
matches = BF.match(dst1, dst2)

# 画出匹配点
img3 = cv.drawMatches(img1, k1, img2, k2, matches[:100], None, flags=2)
cv.imshow("ORB", img3)

cv.waitKey()
cv.destroyAllWindows()




















